/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package alcancia;

/**
 *
 * @author administrador
 */
public class Alcancia {

    private int m20, m50, m100, m200, m500;

    public Alcancia() {
        super();
        m20 = 0;
        m50 = 0;
        m100 = 0;
        m200 = 0;
        m500 = 0;
    }

    public Alcancia(int md100) {
        super();
        m20 = 0;
        m50 = 0;
        m100 = md100;
        m200 = 0;
        m500 = 0;
    }

    public void agregarMoneda(int denominacion,int cantidad) {
        switch (denominacion) {
            case 20:
                this.m20=cantidad;
                break;
            case 50:
                this.m50=cantidad;
                break;
            case 100:
                this.m100=cantidad;
                break;
            case 200:
                this.m200=cantidad;
                break;
            case 500:
                this.m500=cantidad;
                break;
            default:
                System.out.println("Denominación de moneda inexistente");
                break;
        }
    }

    public int contarMonedas(int denominacion) {
        switch (denominacion) {
            case 20:
                return this.m20;
            case 50:
                return this.m50;
            case 100:
                return this.m100;
            case 200:
                return this.m200;
            case 500:
                return this.m500;
            default:
                return 0;
        }
    }

    public int getTotalAhorro() {
        int total = 0;
        total += this.m20 * 20;
        total += this.m50 * 50;
        total += this.m100 * 100;
        total += this.m200 * 200;
        total += this.m500 * 500;
        return total;
    }

    public void vaciarAlcancia() {
        this.m20 = 0;
        this.m100 = 0;
        this.m50 = 0;
        this.m200 = 0;
        this.m500 = 0;
    }
}
